package com.aerozhonghuan.archive.controller;

import com.aerozhonghuan.archive.dto.UpdateResult;
import com.aerozhonghuan.archive.service.ConfigUpdateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/config")
public class ConfigUpdateController {

    private final ConfigUpdateService configUpdateService;

    @Autowired
    public ConfigUpdateController(ConfigUpdateService configUpdateService) {
        this.configUpdateService = configUpdateService;
    }

    /**
     * 更新配置表中所有记录的 last_create_time 字段（更新为对应源表的最大时间）
     */
    @PostMapping("/updateLastCreateTime")
    public List<UpdateResult> updateLastCreateTime() {
        return configUpdateService.updateAllLastCreateTime();
    }
}